1 Background

We compare the inference results from TMB, aghq, adam, and tmbstan. Import these inference results as follows:

tmb <- readRDS("depends/tmb.rds")
aghq <- readRDS("depends/aghq.rds")
adam <- readRDS("depends/adam.rds")
tmbstan <- readRDS("depends/tmbstan.rds")

depends <- yaml::read_yaml("orderly.yml")$depends

1.1 Run details

For more information about the conditions under which these results were generated, see:

1.1.1 TMB

dependency_details <- function(i) {
  report_name <- names(depends[[i]])
  print(paste0("Inference results obtained from ", report_name, " with the query ", depends[[i]][[report_name]]$id))
  report_id <- orderly::orderly_search(query = depends[[i]][[report_name]]$id, report_name)
  print(paste0("Obtained report had ID ", report_id, " and was run with the following parameters:"))
  print(orderly::orderly_info(report_id, report_name)$parameters)
}

dependency_details(1)
## [1] "Inference results obtained from naomi-simple_fit with the query latest(parameter:tmb == TRUE)"
## [1] "Obtained report had ID 20230221-103645-22c5613b and was run with the following parameters:"
## $tmb
## [1] TRUE
## 
## $aghq
## [1] FALSE
## 
## $k
## [1] 2
## 
## $ndConstruction
## [1] "product"
## 
## $tmbstan
## [1] FALSE
## 
## $niter
## [1] 1000
## 
## $nthin
## [1] 1
## 
## $adam
## [1] FALSE
## 
## $nsample
## [1] 5000
## 
## $area_level
## [1] 4

1.1.2 aghq

dependency_details(2)
## [1] "Inference results obtained from naomi-simple_fit with the query latest(parameter:aghq == TRUE && parameter:k == 1)"
## [1] "Obtained report had ID 20230221-104545-c5e8a287 and was run with the following parameters:"
## $aghq
## [1] TRUE
## 
## $k
## [1] 1
## 
## $ndConstruction
## [1] "product"
## 
## $tmb
## [1] FALSE
## 
## $tmbstan
## [1] FALSE
## 
## $niter
## [1] 1000
## 
## $nthin
## [1] 1
## 
## $adam
## [1] FALSE
## 
## $nsample
## [1] 5000
## 
## $area_level
## [1] 4

1.1.3 adam

dependency_details(3)
## [1] "Inference results obtained from naomi-simple_fit with the query latest(parameter:adam == TRUE)"
## [1] "Obtained report had ID 20230221-105031-95fa53bb and was run with the following parameters:"
## $adam
## [1] TRUE
## 
## $tmb
## [1] FALSE
## 
## $aghq
## [1] FALSE
## 
## $k
## [1] 2
## 
## $ndConstruction
## [1] "product"
## 
## $tmbstan
## [1] FALSE
## 
## $niter
## [1] 1000
## 
## $nthin
## [1] 1
## 
## $nsample
## [1] 5000
## 
## $area_level
## [1] 4

1.1.4 tmbstan

dependency_details(4)
## [1] "Inference results obtained from naomi-simple_fit with the query latest(parameter:tmbstan == TRUE)"
## [1] "Obtained report had ID 20230114-142916-efabd65d and was run with the following parameters:"
## $tmbstan
## [1] TRUE
## 
## $niter
## [1] 20000
## 
## $nthin
## [1] 20
## 
## $tmb
## [1] FALSE
## 
## $aghq
## [1] FALSE
## 
## $k
## [1] 2
## 
## $nsample
## [1] 1000

1.2 Time taken

data.frame(
  "TMB" = tmb$time,
  "aghq" = aghq$time,
  "adam" = adam$time,
  "tmbstan" = tmbstan$time
)
adam <- adam$adam

2 Histograms and ECDF difference plots

We create histograms and empirical cumulative distribution function (ECDF) difference plots of the samples from each method. All of the possible parameter names are as follows:

pars <- unique(names(tmb$fit$obj$env$par))
pars
##  [1] "beta_rho"             "beta_alpha"           "beta_lambda"          "beta_anc_rho"         "beta_anc_alpha"      
##  [6] "logit_phi_rho_x"      "log_sigma_rho_x"      "logit_phi_rho_xs"     "log_sigma_rho_xs"     "logit_phi_rho_a"     
## [11] "log_sigma_rho_a"      "logit_phi_rho_as"     "log_sigma_rho_as"     "log_sigma_rho_xa"     "u_rho_x"             
## [16] "us_rho_x"             "u_rho_xs"             "us_rho_xs"            "u_rho_a"              "u_rho_as"            
## [21] "logit_phi_alpha_x"    "log_sigma_alpha_x"    "logit_phi_alpha_xs"   "log_sigma_alpha_xs"   "logit_phi_alpha_a"   
## [26] "log_sigma_alpha_a"    "logit_phi_alpha_as"   "log_sigma_alpha_as"   "log_sigma_alpha_xa"   "u_alpha_x"           
## [31] "us_alpha_x"           "u_alpha_xs"           "us_alpha_xs"          "u_alpha_a"            "u_alpha_as"          
## [36] "u_alpha_xa"           "OmegaT_raw"           "log_betaT"            "log_sigma_lambda_x"   "ui_lambda_x"         
## [41] "log_sigma_ancrho_x"   "log_sigma_ancalpha_x" "ui_anc_rho_x"         "ui_anc_alpha_x"       "log_sigma_or_gamma"  
## [46] "log_or_gamma"

We will produce plots about the following subset of them. There is no particular reason to choose this subset rather than other, it’s quite arbitrary.

pars_eval <- pars %in% c("beta_rho", "beta_alpha", "beta_lambda", "beta_anc_rho", "beta_anc_alpha", "u_rho_x", "us_rho_x", "u_rho_xs")
names(pars_eval) <- pars

The beta_rho parameter is used in other reports as a check, so create the dataframe to save as artefact here:

beta_rho <- histogram_and_ecdf("beta_rho", i = 1, return_df = TRUE)
saveRDS(beta_rho$df, "beta_rho.rds")

2.1 beta_rho

histogram_and_ecdf_helper <- function(par) lapply(1:sum(names(tmb$fit$obj$env$par) == par), histogram_and_ecdf, par = par)
histogram_and_ecdf_helper("beta_rho")
## [[1]]

## 
## [[2]]

2.2 beta_alpha

histogram_and_ecdf_helper("beta_alpha")
## [[1]]

## 
## [[2]]

2.3 beta_lambda

histogram_and_ecdf_helper("beta_lambda")
## [[1]]

## 
## [[2]]

2.4 beta_anc_rho

histogram_and_ecdf("beta_anc_rho")

2.5 beta_anc_alpha

histogram_and_ecdf("beta_anc_alpha")

2.6 logit

lapply(pars[stringr::str_starts(pars, "logit")], histogram_and_ecdf)

2.7 log_sigma

lapply(pars[stringr::str_starts(pars, "log_sigma")], histogram_and_ecdf)

2.8 u_rho_x

histogram_and_ecdf_helper("u_rho_x")
## [[1]]

## 
## [[2]]

## 
## [[3]]

## 
## [[4]]

## 
## [[5]]

## 
## [[6]]

## 
## [[7]]

## 
## [[8]]

## 
## [[9]]

## 
## [[10]]

## 
## [[11]]

## 
## [[12]]

## 
## [[13]]

## 
## [[14]]

## 
## [[15]]

## 
## [[16]]

## 
## [[17]]

## 
## [[18]]

## 
## [[19]]

## 
## [[20]]

## 
## [[21]]

## 
## [[22]]

## 
## [[23]]

## 
## [[24]]

## 
## [[25]]

## 
## [[26]]

## 
## [[27]]

## 
## [[28]]

## 
## [[29]]

## 
## [[30]]

## 
## [[31]]

## 
## [[32]]

2.9 u_rho_x

histogram_and_ecdf_helper("u_rho_x")
## [[1]]

## 
## [[2]]

## 
## [[3]]

## 
## [[4]]

## 
## [[5]]

## 
## [[6]]

## 
## [[7]]

## 
## [[8]]

## 
## [[9]]

## 
## [[10]]

## 
## [[11]]

## 
## [[12]]

## 
## [[13]]

## 
## [[14]]

## 
## [[15]]

## 
## [[16]]

## 
## [[17]]

## 
## [[18]]

## 
## [[19]]

## 
## [[20]]

## 
## [[21]]

## 
## [[22]]

## 
## [[23]]

## 
## [[24]]

## 
## [[25]]

## 
## [[26]]

## 
## [[27]]

## 
## [[28]]

## 
## [[29]]

## 
## [[30]]

## 
## [[31]]

## 
## [[32]]

2.10 us_rho_x

histogram_and_ecdf_helper("us_rho_x")
## [[1]]

## 
## [[2]]

## 
## [[3]]

## 
## [[4]]

## 
## [[5]]

## 
## [[6]]

## 
## [[7]]

## 
## [[8]]

## 
## [[9]]

## 
## [[10]]

## 
## [[11]]

## 
## [[12]]

## 
## [[13]]

## 
## [[14]]

## 
## [[15]]

## 
## [[16]]

## 
## [[17]]

## 
## [[18]]

## 
## [[19]]

## 
## [[20]]

## 
## [[21]]

## 
## [[22]]

## 
## [[23]]

## 
## [[24]]

## 
## [[25]]

## 
## [[26]]

## 
## [[27]]

## 
## [[28]]

## 
## [[29]]

## 
## [[30]]

## 
## [[31]]

## 
## [[32]]

2.11 u_rho_xs

histogram_and_ecdf_helper("u_rho_xs")
## [[1]]

## 
## [[2]]

## 
## [[3]]

## 
## [[4]]

## 
## [[5]]

## 
## [[6]]

## 
## [[7]]

## 
## [[8]]

## 
## [[9]]

## 
## [[10]]

## 
## [[11]]

## 
## [[12]]

## 
## [[13]]

## 
## [[14]]

## 
## [[15]]

## 
## [[16]]

## 
## [[17]]

## 
## [[18]]

## 
## [[19]]

## 
## [[20]]

## 
## [[21]]

## 
## [[22]]

## 
## [[23]]

## 
## [[24]]

## 
## [[25]]

## 
## [[26]]

## 
## [[27]]

## 
## [[28]]

## 
## [[29]]

## 
## [[30]]

## 
## [[31]]

## 
## [[32]]

2.12 us_rho_xs

histogram_and_ecdf_helper("us_rho_xs")

2.13 u_rho_as

histogram_and_ecdf_helper("u_rho_as")

2.14 u_alpha_x

histogram_and_ecdf_helper("u_alpha_x")

2.15 us_alpha_x

histogram_and_ecdf_helper("us_alpha_x")

2.16 u_alpha_xs

histogram_and_ecdf_helper("u_alpha_xs")

2.17 us_alpha_xs

histogram_and_ecdf_helper("us_alpha_xs")
## [[1]]

## 
## [[2]]

## 
## [[3]]

## 
## [[4]]

## 
## [[5]]

## 
## [[6]]

## 
## [[7]]

## 
## [[8]]

## 
## [[9]]

## 
## [[10]]

## 
## [[11]]

## 
## [[12]]

## 
## [[13]]

## 
## [[14]]

## 
## [[15]]

## 
## [[16]]

## 
## [[17]]

## 
## [[18]]

## 
## [[19]]

## 
## [[20]]

## 
## [[21]]

## 
## [[22]]

## 
## [[23]]

## 
## [[24]]

## 
## [[25]]

## 
## [[26]]

## 
## [[27]]

## 
## [[28]]

## 
## [[29]]

## 
## [[30]]

## 
## [[31]]

## 
## [[32]]

2.18 u_alpha_a

histogram_and_ecdf_helper("u_alpha_a")

2.19 u_alpha_as

histogram_and_ecdf_helper("u_alpha_as")

2.20 u_alpha_xa

histogram_and_ecdf_helper("u_alpha_xa")

2.21 ui_lambda_x

histogram_and_ecdf_helper("ui_lambda_x")

2.22 ui_anc_rho_x

histogram_and_ecdf_helper("ui_anc_rho_x")

2.23 ui_anc_alpha_x

histogram_and_ecdf_helper("ui_anc_alpha_x")

2.24 log_or_gamma

histogram_and_ecdf_helper("log_or_gamma")

3 KS plots

3.1 Individual parameters

ks_helper <- function(par, sw = FALSE, ...) {
  to_ks_df(par, starts_with = sw) %>% ks_plot(par, ...)
}

3.1.1 beta

ks_helper("beta", sw = TRUE)
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

ks_helper("beta", sw = TRUE, method1 = "TMB", method2 = "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

3.1.2 logit

ks_helper("logit", sw = TRUE)
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

ks_helper("logit", sw = TRUE, method1 = "TMB", method2 = "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

3.1.3 log_sigma

ks_helper("log_sigma", sw = TRUE)
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

ks_helper("log_sigma", sw = TRUE , method1 = "TMB", method2 = "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

3.1.4 u_rho_x

ks_helper("u_rho_x")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

ks_helper("u_rho_x", method1 = "TMB", method2 = "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

3.1.5 u_rho_xs

ks_helper("u_rho_xs")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

ks_helper("u_rho_xs", method1 = "TMB", method2 = "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

3.1.6 us_rho_x

ks_helper("us_rho_x")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

ks_helper("us_rho_x", method1 = "TMB", method2 = "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).

3.1.7 us_rho_xs

ks_helper("us_rho_xs")
ks_helper("us_rho_xs", method1 = "TMB", method2 = "adam")

3.1.8 u_rho_a

ks_helper("u_rho_a")
ks_helper("u_rho_a", method1 = "TMB", method2 = "adam")

3.1.9 u_rho_as

ks_helper("u_rho_as")
ks_helper("u_rho_as", method1 = "TMB", method2 = "adam")

3.1.10 u_alpha_x

ks_helper("u_alpha_x")
ks_helper("u_alpha_x", method1 = "TMB", method2 = "adam")

3.1.11 u_alpha_xs

ks_helper("u_alpha_xs")
ks_helper("u_alpha_xs", method1 = "TMB", method2 = "adam")

3.1.12 us_alpha_x

ks_helper("us_alpha_x")
ks_helper("us_alpha_x", method1 = "TMB", method2 = "adam")

3.1.13 us_alpha_xs

ks_helper("us_alpha_xs")
ks_helper("us_alpha_xs", method1 = "TMB", method2 = "adam")

3.1.14 u_alpha_a

ks_helper("u_alpha_a")
ks_helper("u_alpha_a", method1 = "TMB", method2 = "adam")

3.1.15 u_alpha_as

ks_helper("u_alpha_as")
ks_helper("u_alpha_as", method1 = "TMB", method2 = "adam")

3.1.16 u_alpha_xa

ks_helper("u_alpha_xa")
ks_helper("u_alpha_xa", method1 = "TMB", method2 = "adam")

3.1.17 ui_anc_rho_x

ks_helper("ui_anc_rho_x")
ks_helper("ui_anc_rho_x", method1 = "TMB", method2 = "adam")

3.1.18 ui_anc_alpha_x

ks_helper("ui_anc_alpha_x")
ks_helper("ui_anc_alpha_x", method1 = "TMB", method2 = "adam")

3.1.19 log_or_gamma

ks_helper("log_or_gamma")
ks_helper("log_or_gamma", method1 = "TMB", method2 = "adam")

3.2 Summary table

options(dplyr.summarise.inform = FALSE)

ks_summary <- lapply(unique(names(tmb$fit$obj$env$par)), function(x) {
  to_ks_df(x) %>%
    group_by(method, index) %>%
    summarise(ks = mean(ks), par = x) %>%
    ungroup()
}) %>%
  bind_rows() %>%
  pivot_wider(names_from = "method", values_from = "ks") %>%
  rename(
    "Parameter" = "par",
    "KS(adam, tmbstan)" = "adam",
    "KS(aghq, tmbstan)" = "aghq",
    "KS(TMB, tmbstan)" = "TMB",
  )

r <- adam$quad$obj$env$random
x_names <- names(adam$quad$obj$env$par[r])
theta_names <- names(adam$quad$obj$env$par[-r])

dict <- data.frame(
  Parameter = c(unique(x_names), unique(theta_names)),
  Type = c(rep("Latent field", length(unique(x_names))), rep("Hyper", length(unique(theta_names))))
)

ks_summary <- ks_summary %>%
  left_join(dict, by = "Parameter")

Values in green are the lowest KS difference for that particular parameter:

ks_summary %>%
  gt::gt() %>%
  gt::fmt_number(
    columns = starts_with("KS"),
    decimals = 3
  ) %>%
  gt::tab_style(
    style = cell_fill(color = "#009E73"),
    locations = cells_body(
      columns = `KS(adam, tmbstan)`,
      rows = `KS(adam, tmbstan)` < `KS(aghq, tmbstan)` & `KS(adam, tmbstan)` < `KS(TMB, tmbstan)`
    )
  ) %>%
    gt::tab_style(
    style = cell_fill(color = "#009E73"),
    locations = cells_body(
      columns = `KS(aghq, tmbstan)`,
      rows = `KS(aghq, tmbstan)` < `KS(adam, tmbstan)` & `KS(aghq, tmbstan)` < `KS(TMB, tmbstan)`
    )
  ) %>%
    gt::tab_style(
    style = cell_fill(color = "#009E73"),
    locations = cells_body(
      columns = `KS(TMB, tmbstan)`,
      rows = `KS(TMB, tmbstan)` < `KS(aghq, tmbstan)` & `KS(TMB, tmbstan)` < `KS(adam, tmbstan)`
    )
  )
index Parameter KS(adam, tmbstan) KS(aghq, tmbstan) KS(TMB, tmbstan) Type
1 beta_rho 0.087 0.082 0.087 Latent field
2 beta_rho 0.086 0.085 0.089 Latent field
1 beta_alpha 0.055 0.058 0.071 Latent field
2 beta_alpha 0.132 0.130 0.131 Latent field
1 beta_lambda 0.048 0.086 0.079 Latent field
2 beta_lambda 0.016 0.024 0.016 Latent field
1 beta_anc_rho 0.046 0.080 0.092 Latent field
1 beta_anc_alpha 0.070 0.027 0.017 Latent field
1 logit_phi_rho_x 0.562 0.562 0.133 Hyper
1 log_sigma_rho_x 0.656 0.656 0.155 Hyper
1 logit_phi_rho_xs 0.510 0.510 0.104 Hyper
1 log_sigma_rho_xs 0.613 0.613 0.212 Hyper
1 logit_phi_rho_a 0.537 0.537 0.058 Hyper
1 log_sigma_rho_a 0.581 0.581 0.110 Hyper
1 logit_phi_rho_as 0.569 0.569 0.113 Hyper
1 log_sigma_rho_as 0.589 0.589 0.142 Hyper
1 log_sigma_rho_xa 0.669 0.669 0.211 Hyper
1 u_rho_x 0.040 0.086 0.085 Latent field
2 u_rho_x 0.021 0.035 0.038 Latent field
3 u_rho_x 0.032 0.027 0.030 Latent field
4 u_rho_x 0.037 0.072 0.084 Latent field
5 u_rho_x 0.081 0.067 0.062 Latent field
6 u_rho_x 0.087 0.101 0.094 Latent field
7 u_rho_x 0.039 0.096 0.089 Latent field
8 u_rho_x 0.090 0.066 0.071 Latent field
9 u_rho_x 0.043 0.080 0.084 Latent field
10 u_rho_x 0.048 0.081 0.076 Latent field
11 u_rho_x 0.037 0.045 0.053 Latent field
12 u_rho_x 0.068 0.127 0.133 Latent field
13 u_rho_x 0.035 0.029 0.039 Latent field
14 u_rho_x 0.059 0.078 0.086 Latent field
15 u_rho_x 0.055 0.035 0.042 Latent field
16 u_rho_x 0.028 0.024 0.021 Latent field
17 u_rho_x 0.022 0.051 0.046 Latent field
18 u_rho_x 0.080 0.044 0.047 Latent field
19 u_rho_x 0.017 0.027 0.029 Latent field
20 u_rho_x 0.018 0.018 0.040 Latent field
21 u_rho_x 0.014 0.038 0.050 Latent field
22 u_rho_x 0.105 0.084 0.084 Latent field
23 u_rho_x 0.048 0.035 0.039 Latent field
24 u_rho_x 0.032 0.033 0.038 Latent field
25 u_rho_x 0.041 0.057 0.045 Latent field
26 u_rho_x 0.059 0.025 0.023 Latent field
27 u_rho_x 0.056 0.068 0.074 Latent field
28 u_rho_x 0.056 0.063 0.060 Latent field
29 u_rho_x 0.078 0.119 0.100 Latent field
30 u_rho_x 0.063 0.057 0.061 Latent field
31 u_rho_x 0.028 0.044 0.028 Latent field
32 u_rho_x 0.034 0.050 0.060 Latent field
1 us_rho_x 0.141 0.163 0.139 Latent field
2 us_rho_x 0.155 0.139 0.119 Latent field
3 us_rho_x 0.096 0.087 0.091 Latent field
4 us_rho_x 0.068 0.069 0.083 Latent field
5 us_rho_x 0.066 0.051 0.068 Latent field
6 us_rho_x 0.182 0.175 0.120 Latent field
7 us_rho_x 0.083 0.072 0.067 Latent field
8 us_rho_x 0.084 0.073 0.076 Latent field
9 us_rho_x 0.068 0.068 0.065 Latent field
10 us_rho_x 0.054 0.047 0.045 Latent field
11 us_rho_x 0.082 0.078 0.088 Latent field
12 us_rho_x 0.083 0.091 0.093 Latent field
13 us_rho_x 0.067 0.050 0.054 Latent field
14 us_rho_x 0.038 0.028 0.046 Latent field
15 us_rho_x 0.043 0.050 0.049 Latent field
16 us_rho_x 0.061 0.054 0.072 Latent field
17 us_rho_x 0.063 0.084 0.076 Latent field
18 us_rho_x 0.117 0.107 0.120 Latent field
19 us_rho_x 0.072 0.082 0.086 Latent field
20 us_rho_x 0.144 0.144 0.143 Latent field
21 us_rho_x 0.104 0.093 0.106 Latent field
22 us_rho_x 0.077 0.064 0.045 Latent field
23 us_rho_x 0.083 0.091 0.070 Latent field
24 us_rho_x 0.070 0.063 0.076 Latent field
25 us_rho_x 0.081 0.107 0.095 Latent field
26 us_rho_x 0.084 0.079 0.084 Latent field
27 us_rho_x 0.044 0.056 0.056 Latent field
28 us_rho_x 0.053 0.054 0.059 Latent field
29 us_rho_x 0.078 0.069 0.076 Latent field
30 us_rho_x 0.087 0.069 0.068 Latent field
31 us_rho_x 0.042 0.041 0.050 Latent field
32 us_rho_x 0.057 0.052 0.076 Latent field
1 u_rho_xs 0.067 0.083 0.087 Latent field
2 u_rho_xs 0.099 0.072 0.077 Latent field
3 u_rho_xs 0.085 0.098 0.100 Latent field
4 u_rho_xs 0.070 0.091 0.095 Latent field
5 u_rho_xs 0.153 0.146 0.140 Latent field
6 u_rho_xs 0.207 0.192 0.170 Latent field
7 u_rho_xs 0.106 0.109 0.102 Latent field
8 u_rho_xs 0.103 0.088 0.096 Latent field
9 u_rho_xs 0.111 0.117 0.119 Latent field
10 u_rho_xs 0.113 0.111 0.107 Latent field
11 u_rho_xs 0.083 0.078 0.087 Latent field
12 u_rho_xs 0.183 0.162 0.152 Latent field
13 u_rho_xs 0.099 0.102 0.112 Latent field
14 u_rho_xs 0.115 0.121 0.127 Latent field
15 u_rho_xs 0.146 0.160 0.144 Latent field
16 u_rho_xs 0.101 0.093 0.088 Latent field
17 u_rho_xs 0.092 0.104 0.090 Latent field
18 u_rho_xs 0.145 0.121 0.133 Latent field
19 u_rho_xs 0.109 0.120 0.126 Latent field
20 u_rho_xs 0.098 0.080 0.104 Latent field
21 u_rho_xs 0.097 0.098 0.100 Latent field
22 u_rho_xs 0.202 0.192 0.173 Latent field
23 u_rho_xs 0.105 0.100 0.123 Latent field
24 u_rho_xs 0.151 0.138 0.148 Latent field
25 u_rho_xs 0.076 0.090 0.086 Latent field
26 u_rho_xs 0.127 0.126 0.120 Latent field
27 u_rho_xs 0.138 0.151 0.145 Latent field
28 u_rho_xs 0.143 0.135 0.141 Latent field
29 u_rho_xs 0.198 0.187 0.178 Latent field
30 u_rho_xs 0.116 0.108 0.115 Latent field
31 u_rho_xs 0.108 0.097 0.102 Latent field
32 u_rho_xs 0.105 0.108 0.105 Latent field
1 us_rho_xs 0.033 0.029 0.019 Latent field
2 us_rho_xs 0.026 0.023 0.020 Latent field
3 us_rho_xs 0.035 0.024 0.026 Latent field
4 us_rho_xs 0.023 0.030 0.020 Latent field
5 us_rho_xs 0.043 0.031 0.027 Latent field
6 us_rho_xs 0.036 0.019 0.021 Latent field
7 us_rho_xs 0.031 0.019 0.032 Latent field
8 us_rho_xs 0.049 0.040 0.038 Latent field
9 us_rho_xs 0.041 0.043 0.047 Latent field
10 us_rho_xs 0.034 0.028 0.037 Latent field
11 us_rho_xs 0.041 0.033 0.036 Latent field
12 us_rho_xs 0.038 0.042 0.036 Latent field
13 us_rho_xs 0.033 0.044 0.052 Latent field
14 us_rho_xs 0.039 0.030 0.044 Latent field
15 us_rho_xs 0.029 0.024 0.035 Latent field
16 us_rho_xs 0.022 0.017 0.015 Latent field
17 us_rho_xs 0.040 0.032 0.037 Latent field
18 us_rho_xs 0.032 0.035 0.045 Latent field
19 us_rho_xs 0.031 0.033 0.035 Latent field
20 us_rho_xs 0.045 0.032 0.054 Latent field
21 us_rho_xs 0.050 0.046 0.040 Latent field
22 us_rho_xs 0.045 0.041 0.040 Latent field
23 us_rho_xs 0.034 0.031 0.037 Latent field
24 us_rho_xs 0.029 0.029 0.029 Latent field
25 us_rho_xs 0.046 0.047 0.059 Latent field
26 us_rho_xs 0.039 0.035 0.040 Latent field
27 us_rho_xs 0.035 0.033 0.036 Latent field
28 us_rho_xs 0.026 0.024 0.023 Latent field
29 us_rho_xs 0.032 0.024 0.031 Latent field
30 us_rho_xs 0.041 0.038 0.044 Latent field
31 us_rho_xs 0.041 0.044 0.045 Latent field
32 us_rho_xs 0.037 0.036 0.037 Latent field
1 u_rho_a 0.087 0.080 0.085 Latent field
2 u_rho_a 0.087 0.084 0.086 Latent field
3 u_rho_a 0.084 0.083 0.086 Latent field
4 u_rho_a 0.083 0.082 0.085 Latent field
5 u_rho_a 0.086 0.082 0.088 Latent field
6 u_rho_a 0.086 0.082 0.086 Latent field
7 u_rho_a 0.087 0.083 0.087 Latent field
8 u_rho_a 0.089 0.083 0.088 Latent field
9 u_rho_a 0.088 0.082 0.087 Latent field
10 u_rho_a 0.086 0.082 0.086 Latent field
1 u_rho_as 0.092 0.086 0.083 Latent field
2 u_rho_as 0.094 0.079 0.082 Latent field
3 u_rho_as 0.094 0.085 0.089 Latent field
4 u_rho_as 0.092 0.082 0.087 Latent field
5 u_rho_as 0.086 0.086 0.088 Latent field
6 u_rho_as 0.091 0.082 0.085 Latent field
7 u_rho_as 0.088 0.086 0.088 Latent field
8 u_rho_as 0.095 0.083 0.089 Latent field
9 u_rho_as 0.092 0.084 0.089 Latent field
10 u_rho_as 0.085 0.077 0.084 Latent field
1 logit_phi_alpha_x 0.512 0.512 0.073 Hyper
1 log_sigma_alpha_x 0.505 0.505 0.127 Hyper
1 logit_phi_alpha_xs 0.551 0.551 0.144 Hyper
1 log_sigma_alpha_xs 0.540 0.540 0.161 Hyper
1 logit_phi_alpha_a 0.534 0.534 0.089 Hyper
1 log_sigma_alpha_a 0.569 0.569 0.107 Hyper
1 logit_phi_alpha_as 0.517 0.517 0.079 Hyper
1 log_sigma_alpha_as 0.514 0.514 0.102 Hyper
1 log_sigma_alpha_xa 0.627 0.627 0.137 Hyper
1 u_alpha_x 0.098 0.139 0.119 Latent field
2 u_alpha_x 0.119 0.130 0.115 Latent field
3 u_alpha_x 0.113 0.108 0.093 Latent field
4 u_alpha_x 0.110 0.124 0.115 Latent field
5 u_alpha_x 0.138 0.146 0.147 Latent field
6 u_alpha_x 0.091 0.091 0.088 Latent field
7 u_alpha_x 0.063 0.061 0.077 Latent field
8 u_alpha_x 0.126 0.137 0.110 Latent field
9 u_alpha_x 0.147 0.146 0.145 Latent field
10 u_alpha_x 0.168 0.137 0.082 Latent field
11 u_alpha_x 0.162 0.154 0.151 Latent field
12 u_alpha_x 0.100 0.074 0.093 Latent field
13 u_alpha_x 0.138 0.126 0.121 Latent field
14 u_alpha_x 0.084 0.084 0.098 Latent field
15 u_alpha_x 0.110 0.082 0.092 Latent field
16 u_alpha_x 0.071 0.063 0.081 Latent field
17 u_alpha_x 0.046 0.055 0.052 Latent field
18 u_alpha_x 0.106 0.094 0.063 Latent field
19 u_alpha_x 0.112 0.114 0.129 Latent field
20 u_alpha_x 0.093 0.103 0.099 Latent field
21 u_alpha_x 0.161 0.161 0.089 Latent field
22 u_alpha_x 0.111 0.128 0.152 Latent field
23 u_alpha_x 0.160 0.146 0.132 Latent field
24 u_alpha_x 0.147 0.149 0.163 Latent field
25 u_alpha_x 0.070 0.106 0.097 Latent field
26 u_alpha_x 0.079 0.097 0.074 Latent field
27 u_alpha_x 0.131 0.143 0.131 Latent field
28 u_alpha_x 0.131 0.116 0.121 Latent field
29 u_alpha_x 0.094 0.105 0.133 Latent field
30 u_alpha_x 0.120 0.119 0.132 Latent field
31 u_alpha_x 0.095 0.086 0.110 Latent field
32 u_alpha_x 0.066 0.063 0.091 Latent field
1 us_alpha_x 0.049 0.078 0.065 Latent field
2 us_alpha_x 0.047 0.077 0.057 Latent field
3 us_alpha_x 0.064 0.070 0.067 Latent field
4 us_alpha_x 0.035 0.043 0.040 Latent field
5 us_alpha_x 0.070 0.079 0.074 Latent field
6 us_alpha_x 0.059 0.058 0.053 Latent field
7 us_alpha_x 0.027 0.034 0.045 Latent field
8 us_alpha_x 0.097 0.074 0.085 Latent field
9 us_alpha_x 0.107 0.091 0.101 Latent field
10 us_alpha_x 0.117 0.097 0.109 Latent field
11 us_alpha_x 0.091 0.071 0.082 Latent field
12 us_alpha_x 0.071 0.047 0.062 Latent field
13 us_alpha_x 0.098 0.070 0.085 Latent field
14 us_alpha_x 0.031 0.021 0.020 Latent field
15 us_alpha_x 0.073 0.043 0.054 Latent field
16 us_alpha_x 0.032 0.040 0.018 Latent field
17 us_alpha_x 0.061 0.067 0.065 Latent field
18 us_alpha_x 0.065 0.055 0.056 Latent field
19 us_alpha_x 0.055 0.064 0.077 Latent field
20 us_alpha_x 0.059 0.075 0.055 Latent field
21 us_alpha_x 0.102 0.089 0.091 Latent field
22 us_alpha_x 0.080 0.103 0.103 Latent field
23 us_alpha_x 0.089 0.090 0.096 Latent field
24 us_alpha_x 0.095 0.086 0.100 Latent field
25 us_alpha_x 0.066 0.073 0.074 Latent field
26 us_alpha_x 0.063 0.073 0.061 Latent field
27 us_alpha_x 0.046 0.055 0.046 Latent field
28 us_alpha_x 0.047 0.044 0.053 Latent field
29 us_alpha_x 0.055 0.064 0.055 Latent field
30 us_alpha_x 0.039 0.064 0.060 Latent field
31 us_alpha_x 0.034 0.036 0.046 Latent field
32 us_alpha_x 0.066 0.052 0.031 Latent field
1 u_alpha_xs 0.064 0.074 0.059 Latent field
2 u_alpha_xs 0.061 0.083 0.064 Latent field
3 u_alpha_xs 0.048 0.060 0.055 Latent field
4 u_alpha_xs 0.099 0.102 0.099 Latent field
5 u_alpha_xs 0.116 0.122 0.129 Latent field
6 u_alpha_xs 0.042 0.064 0.072 Latent field
7 u_alpha_xs 0.049 0.048 0.056 Latent field
8 u_alpha_xs 0.075 0.063 0.051 Latent field
9 u_alpha_xs 0.083 0.078 0.093 Latent field
10 u_alpha_xs 0.105 0.123 0.121 Latent field
11 u_alpha_xs 0.119 0.119 0.115 Latent field
12 u_alpha_xs 0.106 0.125 0.126 Latent field
13 u_alpha_xs 0.078 0.098 0.091 Latent field
14 u_alpha_xs 0.046 0.048 0.062 Latent field
15 u_alpha_xs 0.127 0.125 0.126 Latent field
16 u_alpha_xs 0.153 0.149 0.080 Latent field
17 u_alpha_xs 0.055 0.058 0.054 Latent field
18 u_alpha_xs 0.185 0.178 0.065 Latent field
19 u_alpha_xs 0.079 0.057 0.059 Latent field
20 u_alpha_xs 0.058 0.064 0.064 Latent field
21 u_alpha_xs 0.109 0.100 0.055 Latent field
22 u_alpha_xs 0.198 0.169 0.128 Latent field
23 u_alpha_xs 0.096 0.087 0.106 Latent field
24 u_alpha_xs 0.154 0.153 0.129 Latent field
25 u_alpha_xs 0.142 0.127 0.124 Latent field
26 u_alpha_xs 0.047 0.049 0.060 Latent field
27 u_alpha_xs 0.137 0.129 0.118 Latent field
28 u_alpha_xs 0.085 0.086 0.084 Latent field
29 u_alpha_xs 0.193 0.176 0.094 Latent field
30 u_alpha_xs 0.073 0.069 0.086 Latent field
31 u_alpha_xs 0.114 0.104 0.105 Latent field
32 u_alpha_xs 0.118 0.099 0.081 Latent field
1 us_alpha_xs 0.037 0.055 0.023 Latent field
2 us_alpha_xs 0.037 0.041 0.029 Latent field
3 us_alpha_xs 0.049 0.064 0.041 Latent field
4 us_alpha_xs 0.068 0.054 0.071 Latent field
5 us_alpha_xs 0.090 0.089 0.099 Latent field
6 us_alpha_xs 0.059 0.069 0.074 Latent field
7 us_alpha_xs 0.035 0.034 0.022 Latent field
8 us_alpha_xs 0.110 0.116 0.101 Latent field
9 us_alpha_xs 0.122 0.117 0.117 Latent field
10 us_alpha_xs 0.115 0.130 0.115 Latent field
11 us_alpha_xs 0.119 0.120 0.128 Latent field
12 us_alpha_xs 0.129 0.136 0.145 Latent field
13 us_alpha_xs 0.107 0.106 0.100 Latent field
14 us_alpha_xs 0.093 0.086 0.090 Latent field
15 us_alpha_xs 0.120 0.126 0.118 Latent field
16 us_alpha_xs 0.145 0.138 0.107 Latent field
17 us_alpha_xs 0.047 0.048 0.054 Latent field
18 us_alpha_xs 0.098 0.091 0.050 Latent field
19 us_alpha_xs 0.029 0.024 0.025 Latent field
20 us_alpha_xs 0.035 0.039 0.024 Latent field
21 us_alpha_xs 0.062 0.052 0.044 Latent field
22 us_alpha_xs 0.130 0.130 0.111 Latent field
23 us_alpha_xs 0.106 0.107 0.098 Latent field
24 us_alpha_xs 0.157 0.157 0.144 Latent field
25 us_alpha_xs 0.105 0.096 0.088 Latent field
26 us_alpha_xs 0.154 0.131 0.119 Latent field
27 us_alpha_xs 0.146 0.129 0.130 Latent field
28 us_alpha_xs 0.100 0.097 0.099 Latent field
29 us_alpha_xs 0.160 0.150 0.128 Latent field
30 us_alpha_xs 0.168 0.153 0.139 Latent field
31 us_alpha_xs 0.133 0.134 0.113 Latent field
32 us_alpha_xs 0.113 0.120 0.113 Latent field
1 u_alpha_a 0.052 0.050 0.055 Latent field
2 u_alpha_a 0.054 0.052 0.064 Latent field
3 u_alpha_a 0.057 0.058 0.061 Latent field
4 u_alpha_a 0.071 0.069 0.079 Latent field
5 u_alpha_a 0.051 0.052 0.066 Latent field
6 u_alpha_a 0.051 0.046 0.054 Latent field
7 u_alpha_a 0.050 0.046 0.052 Latent field
8 u_alpha_a 0.053 0.046 0.057 Latent field
9 u_alpha_a 0.050 0.049 0.061 Latent field
10 u_alpha_a 0.054 0.054 0.065 Latent field
11 u_alpha_a 0.062 0.060 0.072 Latent field
12 u_alpha_a 0.060 0.066 0.080 Latent field
13 u_alpha_a 0.055 0.059 0.070 Latent field
1 u_alpha_as 0.070 0.111 0.120 Latent field
2 u_alpha_as 0.099 0.122 0.130 Latent field
3 u_alpha_as 0.142 0.139 0.140 Latent field
4 u_alpha_as 0.145 0.132 0.138 Latent field
5 u_alpha_as 0.148 0.129 0.140 Latent field
6 u_alpha_as 0.137 0.109 0.121 Latent field
7 u_alpha_as 0.102 0.082 0.100 Latent field
8 u_alpha_as 0.089 0.069 0.092 Latent field
9 u_alpha_as 0.064 0.054 0.059 Latent field
10 u_alpha_as 0.051 0.043 0.051 Latent field
1 u_alpha_xa 0.026 0.022 0.021 Latent field
2 u_alpha_xa 0.037 0.023 0.024 Latent field
3 u_alpha_xa 0.020 0.025 0.020 Latent field
4 u_alpha_xa 0.038 0.056 0.060 Latent field
5 u_alpha_xa 0.107 0.111 0.110 Latent field
6 u_alpha_xa 0.087 0.065 0.065 Latent field
7 u_alpha_xa 0.035 0.035 0.035 Latent field
8 u_alpha_xa 0.055 0.048 0.061 Latent field
9 u_alpha_xa 0.043 0.046 0.052 Latent field
10 u_alpha_xa 0.085 0.107 0.098 Latent field
11 u_alpha_xa 0.097 0.106 0.122 Latent field
12 u_alpha_xa 0.116 0.111 0.110 Latent field
13 u_alpha_xa 0.058 0.076 0.070 Latent field
14 u_alpha_xa 0.064 0.062 0.048 Latent field
15 u_alpha_xa 0.044 0.041 0.058 Latent field
16 u_alpha_xa 0.079 0.085 0.066 Latent field
17 u_alpha_xa 0.029 0.047 0.050 Latent field
18 u_alpha_xa 0.055 0.057 0.044 Latent field
19 u_alpha_xa 0.067 0.070 0.061 Latent field
20 u_alpha_xa 0.026 0.036 0.023 Latent field
21 u_alpha_xa 0.062 0.069 0.044 Latent field
22 u_alpha_xa 0.215 0.201 0.179 Latent field
23 u_alpha_xa 0.042 0.053 0.041 Latent field
24 u_alpha_xa 0.083 0.070 0.065 Latent field
25 u_alpha_xa 0.091 0.080 0.074 Latent field
26 u_alpha_xa 0.024 0.042 0.047 Latent field
27 u_alpha_xa 0.079 0.088 0.078 Latent field
28 u_alpha_xa 0.033 0.027 0.020 Latent field
29 u_alpha_xa 0.030 0.038 0.036 Latent field
30 u_alpha_xa 0.040 0.043 0.047 Latent field
31 u_alpha_xa 0.028 0.038 0.030 Latent field
32 u_alpha_xa 0.021 0.035 0.025 Latent field
1 OmegaT_raw 0.518 0.518 0.025 Hyper
1 log_betaT 0.689 0.689 0.245 Hyper
1 log_sigma_lambda_x 0.736 0.736 0.258 Hyper
1 ui_lambda_x 0.158 0.150 0.147 Latent field
2 ui_lambda_x 0.132 0.137 0.144 Latent field
3 ui_lambda_x 0.166 0.153 0.169 Latent field
4 ui_lambda_x 0.147 0.154 0.153 Latent field
5 ui_lambda_x 0.149 0.163 0.154 Latent field
6 ui_lambda_x 0.155 0.137 0.137 Latent field
7 ui_lambda_x 0.149 0.154 0.144 Latent field
8 ui_lambda_x 0.123 0.134 0.133 Latent field
9 ui_lambda_x 0.164 0.158 0.184 Latent field
10 ui_lambda_x 0.240 0.246 0.233 Latent field
11 ui_lambda_x 0.166 0.163 0.161 Latent field
12 ui_lambda_x 0.172 0.179 0.172 Latent field
13 ui_lambda_x 0.180 0.168 0.191 Latent field
14 ui_lambda_x 0.129 0.139 0.134 Latent field
15 ui_lambda_x 0.180 0.175 0.175 Latent field
16 ui_lambda_x 0.155 0.156 0.158 Latent field
17 ui_lambda_x 0.183 0.175 0.181 Latent field
18 ui_lambda_x 0.163 0.154 0.137 Latent field
19 ui_lambda_x 0.172 0.154 0.152 Latent field
20 ui_lambda_x 0.151 0.143 0.141 Latent field
21 ui_lambda_x 0.168 0.155 0.167 Latent field
22 ui_lambda_x 0.157 0.127 0.134 Latent field
23 ui_lambda_x 0.165 0.155 0.162 Latent field
24 ui_lambda_x 0.157 0.157 0.165 Latent field
25 ui_lambda_x 0.156 0.178 0.166 Latent field
26 ui_lambda_x 0.174 0.178 0.174 Latent field
27 ui_lambda_x 0.137 0.142 0.141 Latent field
28 ui_lambda_x 0.149 0.141 0.150 Latent field
29 ui_lambda_x 0.134 0.136 0.135 Latent field
30 ui_lambda_x 0.140 0.134 0.143 Latent field
31 ui_lambda_x 0.145 0.132 0.141 Latent field
32 ui_lambda_x 0.157 0.152 0.164 Latent field
1 log_sigma_ancrho_x 0.504 0.504 0.024 Hyper
1 log_sigma_ancalpha_x 0.520 0.520 0.083 Hyper
1 ui_anc_rho_x 0.037 0.079 0.080 Latent field
2 ui_anc_rho_x 0.020 0.025 0.037 Latent field
3 ui_anc_rho_x 0.032 0.055 0.052 Latent field
4 ui_anc_rho_x 0.037 0.075 0.087 Latent field
5 ui_anc_rho_x 0.019 0.031 0.038 Latent field
6 ui_anc_rho_x 0.081 0.040 0.060 Latent field
7 ui_anc_rho_x 0.034 0.063 0.058 Latent field
8 ui_anc_rho_x 0.070 0.043 0.043 Latent field
9 ui_anc_rho_x 0.033 0.044 0.041 Latent field
10 ui_anc_rho_x 0.027 0.121 0.123 Latent field
11 ui_anc_rho_x 0.015 0.063 0.072 Latent field
12 ui_anc_rho_x 0.051 0.034 0.040 Latent field
13 ui_anc_rho_x 0.020 0.017 0.032 Latent field
14 ui_anc_rho_x 0.042 0.058 0.042 Latent field
15 ui_anc_rho_x 0.022 0.073 0.055 Latent field
16 ui_anc_rho_x 0.025 0.016 0.021 Latent field
17 ui_anc_rho_x 0.025 0.026 0.045 Latent field
18 ui_anc_rho_x 0.033 0.029 0.025 Latent field
19 ui_anc_rho_x 0.046 0.068 0.072 Latent field
20 ui_anc_rho_x 0.021 0.036 0.026 Latent field
21 ui_anc_rho_x 0.031 0.030 0.034 Latent field
22 ui_anc_rho_x 0.077 0.066 0.074 Latent field
23 ui_anc_rho_x 0.018 0.020 0.047 Latent field
24 ui_anc_rho_x 0.055 0.095 0.109 Latent field
25 ui_anc_rho_x 0.030 0.084 0.059 Latent field
26 ui_anc_rho_x 0.024 0.053 0.053 Latent field
27 ui_anc_rho_x 0.068 0.073 0.030 Latent field
28 ui_anc_rho_x 0.026 0.020 0.023 Latent field
29 ui_anc_rho_x 0.076 0.038 0.029 Latent field
30 ui_anc_rho_x 0.026 0.024 0.022 Latent field
31 ui_anc_rho_x 0.027 0.041 0.052 Latent field
32 ui_anc_rho_x 0.028 0.019 0.024 Latent field
1 ui_anc_alpha_x 0.033 0.070 0.076 Latent field
2 ui_anc_alpha_x 0.045 0.052 0.072 Latent field
3 ui_anc_alpha_x 0.079 0.081 0.088 Latent field
4 ui_anc_alpha_x 0.060 0.058 0.061 Latent field
5 ui_anc_alpha_x 0.032 0.037 0.035 Latent field
6 ui_anc_alpha_x 0.028 0.019 0.034 Latent field
7 ui_anc_alpha_x 0.060 0.058 0.070 Latent field
8 ui_anc_alpha_x 0.052 0.059 0.052 Latent field
9 ui_anc_alpha_x 0.059 0.082 0.070 Latent field
10 ui_anc_alpha_x 0.021 0.066 0.058 Latent field
11 ui_anc_alpha_x 0.031 0.029 0.033 Latent field
12 ui_anc_alpha_x 0.048 0.063 0.059 Latent field
13 ui_anc_alpha_x 0.049 0.043 0.053 Latent field
14 ui_anc_alpha_x 0.048 0.060 0.068 Latent field
15 ui_anc_alpha_x 0.068 0.074 0.073 Latent field
16 ui_anc_alpha_x 0.094 0.098 0.033 Latent field
17 ui_anc_alpha_x 0.034 0.036 0.047 Latent field
18 ui_anc_alpha_x 0.138 0.135 0.053 Latent field
19 ui_anc_alpha_x 0.052 0.046 0.050 Latent field
20 ui_anc_alpha_x 0.086 0.070 0.071 Latent field
21 ui_anc_alpha_x 0.075 0.055 0.048 Latent field
22 ui_anc_alpha_x 0.084 0.053 0.039 Latent field
23 ui_anc_alpha_x 0.044 0.048 0.046 Latent field
24 ui_anc_alpha_x 0.055 0.068 0.049 Latent field
25 ui_anc_alpha_x 0.110 0.081 0.087 Latent field
26 ui_anc_alpha_x 0.054 0.054 0.059 Latent field
27 ui_anc_alpha_x 0.041 0.057 0.062 Latent field
28 ui_anc_alpha_x 0.034 0.036 0.028 Latent field
29 ui_anc_alpha_x 0.133 0.120 0.042 Latent field
30 ui_anc_alpha_x 0.056 0.063 0.051 Latent field
31 ui_anc_alpha_x 0.030 0.049 0.040 Latent field
32 ui_anc_alpha_x 0.062 0.053 0.040 Latent field
1 log_sigma_or_gamma 0.524 0.524 0.048 Hyper
1 log_or_gamma 0.022 0.110 0.115 Latent field
2 log_or_gamma 0.027 0.088 0.084 Latent field
3 log_or_gamma 0.033 0.042 0.028 Latent field
4 log_or_gamma 0.042 0.085 0.076 Latent field
5 log_or_gamma 0.044 0.105 0.101 Latent field
6 log_or_gamma 0.056 0.094 0.092 Latent field
7 log_or_gamma 0.022 0.023 0.019 Latent field
8 log_or_gamma 0.044 0.038 0.043 Latent field
9 log_or_gamma 0.046 0.065 0.065 Latent field
10 log_or_gamma 0.017 0.027 0.039 Latent field
11 log_or_gamma 0.013 0.023 0.032 Latent field
12 log_or_gamma 0.018 0.107 0.110 Latent field
13 log_or_gamma 0.020 0.060 0.076 Latent field
14 log_or_gamma 0.025 0.024 0.035 Latent field
15 log_or_gamma 0.035 0.035 0.035 Latent field
16 log_or_gamma 0.041 0.026 0.029 Latent field
17 log_or_gamma 0.033 0.036 0.039 Latent field
18 log_or_gamma 0.041 0.137 0.144 Latent field
19 log_or_gamma 0.027 0.037 0.045 Latent field
20 log_or_gamma 0.018 0.029 0.038 Latent field
21 log_or_gamma 0.049 0.053 0.053 Latent field
22 log_or_gamma 0.026 0.022 0.030 Latent field
23 log_or_gamma 0.023 0.029 0.026 Latent field
24 log_or_gamma 0.015 0.035 0.040 Latent field
25 log_or_gamma 0.052 0.055 0.046 Latent field
26 log_or_gamma 0.029 0.048 0.057 Latent field
27 log_or_gamma 0.024 0.016 0.028 Latent field
28 log_or_gamma 0.051 0.036 0.053 Latent field
29 log_or_gamma 0.021 0.052 0.050 Latent field
30 log_or_gamma 0.050 0.075 0.074 Latent field
31 log_or_gamma 0.037 0.060 0.043 Latent field
32 log_or_gamma 0.017 0.041 0.055 Latent field

This plot could be improved by making the red to green transition smooth, then adding legend for KS difference. The density plots could be filled according to KS difference.

summary_ks_plot <- function(ks_summary, method1, method2) {
  ks_method1 <- paste0("KS(", method1, ", tmbstan)")
  ks_method2 <- paste0("KS(", method2, ", tmbstan)")
  
  xy_length <- min(1, max(ks_summary[[ks_method1]], ks_summary[[ks_method2]]) + 0.05)
  
  x <- y <- seq(0, xy_length, length.out = 20)

  gradient_base <- expand.grid(x, y) %>%
    mutate(diff = Var1 - Var2) %>%
    ggplot(aes(x = Var1, y = Var2)) +
    geom_tile(aes(fill = diff), alpha = 0.7) +
    scale_fill_gradientn(
      colours = c("#56B4E9", "white", "#009E73"),
      rescaler = ~ scales::rescale_mid(.x, mid = 0)
    )
  
  densityplot <- gradient_base +
    stat_density_2d(data = ks_summary, aes(x = .data[[ks_method1]], y = .data[[ks_method2]], linetype = Type), col = "black") +
    xlim(0, xy_length) +
    ylim(0, xy_length) +
    geom_abline(intercept = 0, slope = 1, linetype = "dashed", alpha = 0.5) +
    scale_linetype_manual(values = c("solid", "dashed")) +
    labs(x = ks_method1, y = ks_method2) +
    theme_minimal() +
    guides(fill = "none") +
    theme(
      legend.position = "bottom"
    )
  
  ks_summary[["KS difference"]] <- ks_summary[[ks_method1]] - ks_summary[[ks_method2]]
  
  ridgeplot <- ggplot(ks_summary, aes(y = Type, x = `KS difference`)) +
    ggridges::geom_density_ridges(alpha = 0.7, fill = NA, aes(linetype = Type)) +
    coord_flip() +
    scale_linetype_manual(values = c("solid", "dashed")) +
    labs(y = "", x = paste0(ks_method1, " - ", ks_method2)) +
    guides(linetype = FALSE) +
    theme_minimal()

  densityplot + ridgeplot
}

summary_ks_plot(ks_summary, "TMB", "aghq")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).
## Picking joint bandwidth of 0.00982

summary_ks_plot(ks_summary, "TMB", "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).
## Picking joint bandwidth of 0.0103

summary_ks_plot(ks_summary, "aghq", "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).
## Picking joint bandwidth of 0.24

(ks_summary_out <- ks_summary %>%
  group_by(Type) %>%
  summarise(
    TMB = mean(`KS(TMB, tmbstan)`),
    aghq = mean(`KS(aghq, tmbstan)`),
    adam = mean(`KS(adam, tmbstan)`)
  ))

Compute \(p\)-values, then plot expecting \(\mathcal{U}(0, 1)\). If not conclude there is a significant difference.

#' To write!

Save some things for output:

pdf("ks_summary_tmb_adam.pdf", h = 4, w = 6.25)
summary_ks_plot(ks_summary, "TMB", "adam")
## Warning: Removed 76 rows containing missing values (`geom_tile()`).
## Picking joint bandwidth of 0.0103
dev.off()
## quartz_off_screen 
##                 2
saveRDS(ks_summary_out, "ks_summary_out.rds")

3.3 Investigation into large KS values

The following parameters have KS values greater than 0.5 in both dimensions.

(big_ks <- ks_summary %>%
  filter(`KS(aghq, tmbstan)` + `KS(TMB, tmbstan)` > 0.5) %>%
  pull(Parameter))
##  [1] "logit_phi_rho_x"      "log_sigma_rho_x"      "logit_phi_rho_xs"     "log_sigma_rho_xs"     "logit_phi_rho_a"     
##  [6] "log_sigma_rho_a"      "logit_phi_rho_as"     "log_sigma_rho_as"     "log_sigma_rho_xa"     "logit_phi_alpha_x"   
## [11] "log_sigma_alpha_x"    "logit_phi_alpha_xs"   "log_sigma_alpha_xs"   "logit_phi_alpha_a"    "log_sigma_alpha_a"   
## [16] "logit_phi_alpha_as"   "log_sigma_alpha_as"   "log_sigma_alpha_xa"   "OmegaT_raw"           "log_betaT"           
## [21] "log_sigma_lambda_x"   "log_sigma_ancrho_x"   "log_sigma_ancalpha_x" "log_sigma_or_gamma"

4 MMD

#' To write!

5 PSIS

Suppose we have two sets of samples from the posterior. For each sample we are going to want to evaluate the log-likelihood, so that we can calculate the log-likelihood ratios. We can extract the TMB objective function for the log-likelihood as follows:

tmb$fit$obj$fn()
## [1] NaN
#' To write!